#!/bin/sh

if [[ $EUID -ne 0 ]]; then
  echo "This script must be run as root" 1>&2
  exit 1
fi

echo "Preparing your system for omnimysql"

printf "Installing Pod::Usage ... "
perl -MCPAN -e'install Pod::Usage' >> /dev/null

if [[ $? -eq 0 ]]; then
  printf "OK\n"
else
  printf "FAILED\N"
  exit 1
fi

printf "Installing Getopt::Long ... "
perl -MCPAN -e'install Getopt::Long' >> /dev/null

if [[ $? -eq 0 ]]; then
  printf "OK\n"
else
  printf "FAILED\N"
  exit 1
fi

printf "Installing DBI ... "
perl -MCPAN -e'install DBI' >> /dev/null

if [[ $? -eq 0 ]]; then
  printf "OK\n"
else
  printf "FAILED\N"
  exit 1
fi

printf "Installing SQL::Parser ... "
perl -MCPAN -e'install SQL::Parser' >> /dev/null

if [[ $? -eq 0 ]]; then
  printf "OK\n"
else
  printf "FAILED\N"
  exit 1
fi

printf "Installing XML::Simple ... "
perl -MCPAN -e'install XML::Simple' >> /dev/null

if [[ $? -eq 0 ]]; then
  printf "OK\n"
else
  printf "FAILED\N"
  exit 1
fi

